<?php
/**
 * Copyright 2013 Marek Kaszewski
 *
 * This file is part of the JHUB1 Online Community Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Jhub1_Common\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Jhub1_Common\Model\SettingsObjects\AgentLocalConfigurationObject;
use Jhub1_Common\Model\SettingsObjects\AgentRemoteConfigurationObject;
use Jhub1_Common\Model\SettingsObjects\DateTimeObject;

/**
 * @ORM\Entity
 * @ORM\Table(name="jhoEndpointValues", indexes={@ORM\Index(name="uuid_index", columns={"id"})})
 */
class EndpointValues extends POBase
{

    /**
     * @ORM\Column(type="string", name="agents_username", length=64, nullable=false);
     * @var string
     */
    private $agentUsername;

    /**
     * @ORM\Column(type="string", name="name", length=250, nullable=false);
     * @var string
     */
    private $name;

    /**
     * @ORM\Column(type="string", name="value", length=250, nullable=true);
     * @var string
     */
    private $value;


    public function __construct(Agents $agent)
    {
        $this->setAgent($agent->getUserame());
        $this->setCreated(new DateTimeObject());
    }

    /** @param Agents $agent */
    public function setAgent($agentUsername)
    {
        $this->agentUsername = $agentUsername;
    }

    public function getAgent()
    {
        return $this->agentUsername;
    }

    public function getValue()
    {
        return $this->value;
    }

    public function setValue($val)
    {
        $this->value = $val;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($val)
    {
        $this->name = $val;
    }

    public function toString()
    {
        $string           = '---------------------------------------------'. PHP_EOL;
        $string = $string . 'ENDPOINT VALUE OBJECT:                   ' . PHP_EOL;
        $string = $string . '---------------------------------------------'. PHP_EOL;
        $string = $string . 'ID:                       ' . $this->getId() . PHP_EOL;
        $string = $string . 'Agent Username:           ' . $this->getAgent() . PHP_EOL;
        $string = $string . 'Name:                     ' . $this->getName() . PHP_EOL;
        $string = $string . 'Value:                    ' . $this->getValue() . PHP_EOL;
        $string = $string . 'Created:                  ' . PHP_EOL . $this->getCreated()->toString() . PHP_EOL;
        $string = $string . 'Updated:                  ' . PHP_EOL . $this->getUpdated()->toString() . PHP_EOL;
        return $string;
    }
}